- can_add_new_domain = can_create_pages_custom_domains?(current_user, @project)
- verification_enabled = Gitlab::CurrentSettings.pages_domain_verification_enabled?

- if can?(current_user, :update_pages, @project)
  = render ::Layouts::CrudComponent.new(s_('GitLabPages|Domains'),
    icon: 'earth',
    count: @domains.size,
    count_options: { class: 'js-admin-labels-count' }) do |c|
    - c.with_actions do
      - if can_add_new_domain
        = render Pajamas::ButtonComponent.new(size: :small, href: new_project_pages_domain_path(@project)) do
          = s_('GitLabPages|Add domain')

    - c.with_body do
      - if @domains.any?
        %ul.content-list
          - @domains.each do |domain|
            %li
              .gl-flex.gl-justify-between.gl-items-start
                .gl-flex.gl-flex-col.gl-gap-2.gl-mt-2
                  .domain-name
                    = external_link(domain.url, domain.url)
                  - if verification_enabled
                    .gl-flex.gl-gap-2.gl-items.center.gl-text-sm
                      - if domain.unverified?
                        %span.gl-text-danger
                          = sprite_icon("status-alert", size: 12)
                          = s_('GitLabPages|DNS check unsuccessful')
                      - elsif domain.certificate && domain.pages_domain.subject
                        %span.gl-text-subtle
                          = sprite_icon("status-success", size: 12)
                          = s_('GitLabPages|DNS check successful')
                .gl-flex.gl-gap-2
                  = render Pajamas::ButtonComponent.new(href: project_pages_domain_path(@project, domain),
                    icon: 'pencil',
                    category: :tertiary,
                    button_options: { title: s_('GitLabPages|Edit'), data: { toggle: 'tooltip', container: 'body' } })
                  = render Pajamas::ButtonComponent.new(href: project_pages_domain_path(@project, domain),
                    icon: 'remove',
                    category: :tertiary,
                    button_options: { title: s_("GitLabPages|Remove domain"), "aria-label": s_("GitLabPages|Remove domain"), data: { method: :delete, confirm: s_('GitLabPages|Are you sure?'), 'confirm-btn-variant': 'danger', toggle: 'tooltip', container: 'body' } })
              - if domain.needs_verification?
                .gl-mt-3
                  = render Pajamas::AlertComponent.new(dismissible: false,
                    variant: :warning) do |c|
                    - c.with_body do
                      = s_('GitLabPages|Domain ownership verification required. Add a TXT record to verify ownership at your domain provider.')
                    - c.with_actions do
                      = render Pajamas::ButtonComponent.new(href: project_pages_domain_path(@project, domain)) do
                        = s_("GitLabPages|Edit domain")
              - if domain.show_auto_ssl_failed_warning?
                .gl-mt-3
                  - details_link_start = "<a href='#{project_pages_domain_path(@project, domain)}'>".html_safe
                  - details_link_end = '</a>'.html_safe
                  = render Pajamas::AlertComponent.new(dismissible: false,
                    variant: :warning) do |c|
                    - c.with_body do
                      = s_("GitLabPages|Something went wrong while obtaining the Let's Encrypt certificate for %{domain}. To retry visit your %{link_start}domain details%{link_end}.").html_safe % { domain: domain.domain,
                          link_start: details_link_start,
                          link_end: details_link_end }
      - else
        %span.gl-text-subtle= s_("You currently have no custom domains.")
